
import type { UploadUserFile } from "element-plus";

// UploadUserFile[]

export interface GetSpuListApiParams {
    page:number
    limit:number
    category3Id:number
}

/*
{
  "records": [
    {
      "id": 6,
      "spuName": "S10 Pro",
      "description": "产品名称\nS10 Pro\n品牌\nvivo\n首销日期\n以官网信息为准\n入网型号\nV2121A\n上市年份\n2021年\n上市月份\n7月",
      // "category3Id": 61,
      // "tmId": 6,
      // "spuSaleAttrList": null,
      // "spuImageList": null,
      // "spuPosterList": null
    }
  ],
  "total": 6,
}
*/

export interface SpuItem{
    id?:number
    spuName:string
    description:string
}

export type SpuList = SpuItem[]

export interface GetSpuListApiResponse{
    records:SpuList
    total:number
}
export interface Spu {
  id?: number;
  category3Id?: number;
  spuName: string;
  tmId: number | undefined;
  description: string;
  spuSaleAttrList: SpuSaleAttrList;
}

export interface SpuItem extends Spu {
  spuImageList: SpuImageList; // 发送请求，接口需要的类型
}

export interface SaveSpuItem extends Spu {
  spuImageList: UploadUserFile[]; // element-plus定义的数据，收集到的数据类型
}
// 基础销售属性
/*
  [
    {
      id: 1,
      name: xxx
    }
  ]
*/
export interface BaseSaleAttrItem{
  id:number,
  name:string
}

export type BaseSaleAttrList = BaseSaleAttrItem[]


/* {
  "spuName": "string",
  "tmId": 0,
  "description": "string",
  "category3Id": 0,
  "spuImageList": [
    {
      "imgName": "string",
      "imgUrl": "string",
    }
  ],
  "spuSaleAttrList": [
    {
      "baseSaleAttrId": 0, // 基础销售属性id
      "saleAttrName": "string", // 销售属性名
      "spuSaleAttrValueList": [ // 销售属性值列表
        {
          "baseSaleAttrId": 0, // 基础销售属性id
          "saleAttrValueName": "string", // 销售属性值名
        }
      ],
    }
  ],
} */


// 销售属性值
export interface SpuSaleAttrValueItem {
  baseSaleAttrId: number;
  saleAttrValueName: string;
  id?:number
}

export type SpuSaleAttrValueList = SpuSaleAttrValueItem[];

// 销售属性
export interface SpuSaleAttrItem {
  baseSaleAttrId: number; // 基础销售属性id
  saleAttrName: string;
  spuSaleAttrValueList: SpuSaleAttrValueList;
  isEdit: boolean; // 是否编辑模式
  id?:number
}

export type SpuSaleAttrList = SpuSaleAttrItem[];


// 上传图片类型
export interface SpuImageItem {
  imgName: string;
  imgUrl: string;
}

export type SpuImageList = SpuImageItem[];


